package com.mario;

import java.awt.Graphics;
import java.awt.Rectangle;

public class Coin extends Powerup{
	
	boolean dead = false;
	Rectangle collisionbox = new Rectangle();
	int x,y;
	ImageHelper im = new ImageHelper();
	
	public Coin(int x1, int y1){
		x=x1;y=y1;
		im.setDim(12, 12, 1);
		im.parse("null, null, null, null, (0:0:0), (0:0:0), (0:0:0), (0:0:0), null, null, null, null, null, null, null, (0:0:0), (255:200:0), (255:200:0), (255:200:0), (255:200:0), (0:0:0), null, null, null, null, null, (0:0:0), (255:200:0), (255:255:0), (255:255:0), (255:255:0), (255:255:0), (255:200:0), (0:0:0), null, null, null, (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), null, (0:0:0), (255:200:0), (255:255:0), (255:200:0), (255:200:0), (255:255:0), (255:255:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (255:255:0), (255:255:0), (255:255:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (255:255:0), (255:255:0), (255:255:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (255:200:0), (255:255:0), (255:255:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), null, (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), null, null, null, (0:0:0), (255:200:0), (255:255:0), (255:255:0), (255:255:0), (255:255:0), (255:200:0), (0:0:0), null, null, null, null, null, (0:0:0), (255:200:0), (255:200:0), (255:200:0), (255:200:0), (0:0:0), null, null, null, null, null, null, null, (0:0:0), (0:0:0), (0:0:0), (0:0:0), null, null, null, null");
	}
	
	public Coin(){
		im.setDim(12, 12, 1);
		im.parse("null, null, null, null, (0:0:0), (0:0:0), (0:0:0), (0:0:0), null, null, null, null, null, null, null, (0:0:0), (255:200:0), (255:200:0), (255:200:0), (255:200:0), (0:0:0), null, null, null, null, null, (0:0:0), (255:200:0), (255:255:0), (255:255:0), (255:255:0), (255:255:0), (255:200:0), (0:0:0), null, null, null, (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), null, (0:0:0), (255:200:0), (255:255:0), (255:200:0), (255:200:0), (255:255:0), (255:255:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (255:255:0), (255:255:0), (255:255:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (255:255:0), (255:255:0), (255:255:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (255:200:0), (255:255:0), (255:255:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), null, (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), (0:0:0), (255:200:0), (255:255:0), (255:200:0), (0:0:0), null, null, null, (0:0:0), (255:200:0), (255:255:0), (255:255:0), (255:255:0), (255:255:0), (255:200:0), (0:0:0), null, null, null, null, null, (0:0:0), (255:200:0), (255:200:0), (255:200:0), (255:200:0), (0:0:0), null, null, null, null, null, null, null, (0:0:0), (0:0:0), (0:0:0), (0:0:0), null, null, null, null");
	}
	
	public boolean collides(){
		return collisionbox.intersects(StaticStuff.mario.collisionbox);
	}
	
	public void update(){
		if(!dead){
		collisionbox.setRect(x,y,20,20);
		if(collides()){
			dead=true;GameFrame.score+=200;}
		}else{
			collisionbox.setRect(0,0,0,0);
		}
			
	}
	
	public void draw(Graphics g){
		if(!dead)
			im.paint(g, im.ca, x, y);
	}
	
	public String toString(){
		return "Coin";
	}
}
